const useUserStore=defineStore('user',{
    state:()=>({
        nickName:'邦道',
        avatarUrl:'http://114.132.150.204/avatar.jpg',
        permissions:[]//权限
    }),
    getters:{
        isLogin: state => {
            let retn = false
            if (state.token) {
                retn = true
            }
            return true
        }
    },
    actions: {
        login(data) {
            return new Promise((resolve, reject) => {
                this.token='sssssssssss'
                localStorage.setItem('token','sssssssssssssss')
                resolve()
            })
        },
        logout() {
            return new Promise(resolve => {
                const routeStore = useRouteStore()
                localStorage.removeItem('token')
                this.token = ''
                routeStore.removeRoutes()
                resolve()
            })
        },
        // 获取我的权限
        getPermissions() {
            return new Promise(resolve => {
                this.permissions = ['admin']
                resolve(['admin'])
            })
        },
    }
})

export default useUserStore